package cn.net.xyan.easy.gwt.client.ui.cell;

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.Cell;
import com.google.gwt.cell.client.CompositeCell;
import com.google.gwt.cell.client.HasCell;
import com.google.gwt.dom.client.Element;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;


import java.util.LinkedList;
import java.util.List;


/**
 * Created by zarra on 16/3/3.
 */
public class ListCell<C>  {



    List<HasCell<C,?>> cells = new LinkedList<>();

    public void addCell(HasCell<C,?> hasCell){
        cells.add(hasCell);
    }


    public  CompositeCell<C> getCell(){
        CompositeCell<C> compCell = new CompositeCell<>(cells);
        return compCell;
    }

//
//    @Override
//    public void render(Context context, C value, SafeHtmlBuilder sb) {
//        for (HasCell<T, C> hasCell : cells) {
//            render(context, null, sb, hasCell);
//        }
//    }
//
//    /**
//     * Render the composite cell as HTML into a {@link SafeHtmlBuilder}, suitable
//     * for passing to {@link Element#setInnerHTML} on a container element.
//     *
//     * <p>
//     * Note: If your cell contains natively focusable elements, such as buttons or
//     * input elements, be sure to set the tabIndex to -1 so that they do not steal
//     * focus away from the containing widget.
//     * </p>
//     *
//     * @param context the {@link com.google.gwt.cell.client.Cell.Context Context} of the cell
//     * @param value the cell value to be rendered
//     * @param sb the {@link SafeHtmlBuilder} to be written to
//     * @param hasCell a {@link HasCell} instance containing the cells to be
//     *          rendered within this cell
//     */
//    protected  void render(Context context, T value,
//                              SafeHtmlBuilder sb, HasCell<T,C> hasCell) {
//        Cell<C> cell = hasCell.getCell();
//        sb.appendHtmlConstant("<span>");
//        cell.render(context, hasCell.getValue(value), sb);
//        sb.appendHtmlConstant("</span>");
//    }
}
